package cn.iocoder.yudao.module.member.bonus.controller.app;

import cn.iocoder.yudao.framework.business.order.pojo.vo.OrderSubmitVO;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.api.member.bonus.vo.BonusOrderVO;
import cn.iocoder.yudao.module.member.bonus.pojo.dto.BonusOrderSubmitDTO;
import cn.iocoder.yudao.module.member.bonus.service.app.AppBonusOrderService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.*;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;

/**
 * <pre>
 * OOoO0OOoO0OOOooo0oOOOO0OOOOO0oooOO0ooOOO0Ooooo0OOOOo0ooooO0OOooo0Ooooo0OOOOO
 * 前端控制器
 * OOoO0OOoO0OOOooo0oOOOO0OOOOO0oooOO0ooOOO0Ooooo0OOOOo0ooooO0OOooo0Ooooo0OOOOO
 * </pre>
 *
 * @author 山野羡民（1032694760@qq.com）
 * @since 2025/05/09
 */
@Tag(name = "用户 APP - 分红人员缴费订单")
@RestController
@RequestMapping("/member/bonus/order")
public class AppBonusOrderController {
    @Resource
    private AppBonusOrderService appBonusOrderService;

    @Operation(summary = "分页")
    @GetMapping("/page")
    public CommonResult<PageResult<BonusOrderVO>> getPage(@Valid PageParam param) {
        return success(appBonusOrderService.getPage(param.getPageNo(), param.getPageSize(), getLoginUserId()));
    }

    @PostMapping("/create")
    @Operation(summary = "创建订单", description = "购买分红人员身份订单，返回交易单号")
    public CommonResult<OrderSubmitVO> submit(@Valid @RequestBody BonusOrderSubmitDTO reqVO) {
        OrderSubmitVO respVO = appBonusOrderService.submit(reqVO, getLoginUserId());
        return success(respVO);
    }

}
